package org.example.finalsecurities.controller;

import org.example.finalsecurities.entity.FlowInfo;
import org.example.finalsecurities.service.FlowInfoService;
import org.example.finalsecurities.utils.UnicodeDecoder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 戴诚棋
 * @version 1.0
 */
@RestController
@RequestMapping("/api/flowInfo")
public class FlowInfoController {
    @Autowired
    private FlowInfoService flowInfoService;
    @GetMapping("/insert")
    public void insertFlowInfo() {
        flowInfoService.insertFlowInfo();
    }
    //查询数据，通过json返回
    @GetMapping("/select")
    public List<FlowInfo> selectFlowInfo() {
        //获取数据库表信息
        List<FlowInfo> flowInfoList = flowInfoService.getFlowInfoList();
        for (FlowInfo flowInfo : flowInfoList) {
            flowInfo.setName(UnicodeDecoder.decode(flowInfo.getName()));
        }
        return flowInfoService.getFlowInfoList();
    }
}
